/**
 * AbstractSwarmModel.java
 * Created: 14.03.2011, 16:45:55
 */
package model;

import java.util.Observable;

/**
 * A base class for the model. It implements the methods of
 * {@link SwarmInterface} and extends {@link Observable} thus implements the
 * Observable/Observer design pattern. The observers should be informed whenever
 * the swarm model is changed, that is when a move happened or when a new counter
 * is introduced.
 * @author Jan-Philipp Kappmeier
 */
public abstract class AbstractSwarmModel extends Observable implements SwarmInterface {
	
	/**
	 * Notifies the listening observers. The only possible message that can be
	 * handled is of the type {@link PieceNotification}. If any other message
	 * is passed an exception is thrown.
	 * @param message the {@link PieceNotification} message.
	 * @throws IllegalArgumentException if the passed argument is not of the type {@link PieceNotification}
	 */
	@Override
	public void notifyObservers( Object message ) throws IllegalArgumentException {
		if( !(message instanceof PieceNotification) )
			throw new IllegalArgumentException();
		setChanged();
		super.notifyObservers( message );
	}
	
}
